package com.hb.trade.server.project.notice.manager;

import cn.hutool.extra.spring.SpringUtil;
import com.hb.core.pojo.enums.NoticeNatureEnum;
import com.hb.core.pojo.project.notice.dto.NoticeDTO;
import org.fzzn.core.model.enums.MsgEnum;
import org.fzzn.core.util.Enums;

/**
 * 公告相关处理逻辑
 *
 * @author zhaojk
 */
public class NoticeManager extends NoticeDTO {

    /**
     * 根据前端传值noticeFormFlag获取响应的公告处理service
     *
     * @return
     */
    public NoticeSave getSaveService() {
        Integer noticeFormFlag = getNoticeFormFlag();
        if (noticeFormFlag == null) {
            throw new RuntimeException(MsgEnum.INCORRECT_PARAM.msg());
        }

        switch (noticeFormFlag) {
            // 执行带标段的公告保存或者更新
            case 1:
                Integer noticeNature = getNoticeNature();
                NoticeNatureEnum natureEnum = Enums.of(NoticeNatureEnum.class, noticeNature);
                switch (natureEnum) {
                    case FIRST:
                        return SpringUtil.getBean(NoticeSaveFirst.class);
                    case CHANGE:
                        return SpringUtil.getBean(NoticeSaveChange.class);
                    case DELAY:
                        return SpringUtil.getBean(NoticeSaveDelay.class);
                    case SUP:
                        return SpringUtil.getBean(NoticeSaveSup.class);
                    case TERMIN:
                        return SpringUtil.getBean(NoticeSaveTermin.class);
                    case AGAIN:
                        return SpringUtil.getBean(NoticeSaveAgain.class);
                    case LIMIT:
                        return SpringUtil.getBean(NoticeSaveLimitPrice.class);
                    case FAILURE:
                        return SpringUtil.getBean(NoticeSaveFailure.class);
                }
            // 只保存公告内容和签过章的公告PDF文件
            case 2:
                return SpringUtil.getBean(NoticeSaveContent.class);
            default:
        }
        return null;
    }


}
